<?php
/**
 * @author 陈韵
 * 景彤供应商订单
 */
namespace App\Service\OrderService\OrderRouteService;
use App\Service\Code\Normal;
use App\Service\VendorClient\Shopjingtong\ShopjingtongApiClient;
use App\Service\OrderService\BaseSupplierRouterService;
use App\Service\TraitService\SupplierRouterOrderTrait;

class Shopjingtong extends BaseSupplierRouterService 
{

    use SupplierRouterOrderTrait;

    /**
     * 订单支付
     * @param array $param
     * @return mixed
     */
    public function orderPay( $param = [] )
    {
        return $this->callSdkApi(ShopjingtongApiClient::class,$param['apiBody'])->createOrder($param);

    }

    /**
     * 订单取消
     * @param array $param
     * @return mixed
     */
    public function orderCancel( $param = [] )
    {
        return Normal::returnCode(Normal::SUC,"处理完成");
    }

    /**
     * 订单售后
     * @param array $param
     * @return mixed
     */
    public function orderAfterSale($param = [])
    {
        return Normal::returnCode(Normal::SUC,"处理完成");
    }
    
    /**
     * 订单发货
     * @param array $param
     * @return mixed
     */
    public function queryOrderExpress($param = [])
    {
        return Normal::returnCode(Normal::SUC,"处理完成");
    }
    
    /**
     * 商品列表查询接口
     * @param array $param
     * @return mixed
     */
    public function queryGoodsList( $param = [] )
    {
        $res = $this->callSdkApi(ShopjingtongApiClient::class,$param['apiBody'])->queryGoodsList($param['queryBody']);
        if($res["code"] != Normal::SUC){
            return $res;
        }
        return Normal::returnCode(Normal::SUC,"获取成功",[
            'total'     => $res["data"]["data"]["total"]? $res["data"]["data"]["total"] : 0,
            'list'      => $res["data"]["data"]["rows"],
            'has_next'  => isset($res["data"]["has_next"]) ?? false
        ]);
    }
    
}